﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MagicBag.CRM.Model;
using MagicBag.CRM.IDAL;

namespace MagicBag.CRM.BLL
{
    public class RoleMenuBLL
    {
        //创建数据访问对象
        private static readonly IRoleMenu roleMenuDAL = DALFactory.DataAccess.CreateRoleMenu();

        /// <summary>
        /// 添加菜单
        /// </summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        public int Insert(RoleMenu roleMenu)
        {
            return roleMenuDAL.Insert(roleMenu);
        }

        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Delete(int roleID, int menuID)
        {
            return roleMenuDAL.Delete(roleID, menuID);
        }

        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        public int Update(RoleMenu roelMenu)
        {
            return roleMenuDAL.Update(roelMenu);
        }

        /// <summary>
        /// 获取所有菜单
        /// </summary>
        /// <returns></returns>
        public IList<RoleMenu> GetMenus()
        {
            return roleMenuDAL.GetRoleMenus();
        }

        /// <summary>
        /// 获取指定角色的所有菜单
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public IList<RoleMenu> GetRoleMenusByRoleID(int roleID)
        {
            return roleMenuDAL.GetRoleMenusByRoleID(roleID);
        }
    }
}
